<div class='toolbar'>
  <ul class='actions'>
    <li>
      <p><%= button_link_to t("new_wholesaler"), new_object_url, :icon => 'add' %></p>
    </li>
  </ul>
  <br class='clear' />
</div>


<h1><%= t("listing_wholesalers") %></h1>


<table class="index">
  <thead>
  <tr>
    <th><%= sort_link @search, :company, t('wholesaler') %></th>
    <th><%= sort_link @search, :buyer_contact, t('buyer_contact') %></th>
    <th><%= sort_link @search, :user_email, t('email') %></th>
    <th><%= sort_link @search, :phone, t('phone') %></th>
    <th><%= t('active') %></th>
    <th>
    </th>
  </tr>
  </thead>
  <tbody>
    <% @wholesalers.each do |wholesaler|%>
      <tr id="<%= dom_id wholesaler %>">
        <%- locals = {:wholesaler => wholesaler} %>
        <td><%=link_to wholesaler.company, object_url(wholesaler) %></td>
        <td><%= wholesaler.buyer_contact %></td>
        <td><%= mail_to wholesaler.email %></td>
        <td><%= wholesaler.phone %></td>
        <td width="50px"><%= wholesaler.roles.include?("wholesale") ? 'yes' : 'no' %></td>
        <td>
          <%= link_to_edit wholesaler %> &nbsp;
          <%= link_to_delete wholesaler %> &nbsp;
          <%= render 'user_options', :wholesaler => wholesaler %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>

<%= paginate @wholesalers %>



<% content_for :sidebar do %>
<div class="box">
  <h3><%= t('search') %></h3>

  <% @wholesaler = Spree::Wholesaler.search %>

  <%= search_form_for [:admin, @wholesaler] do |f| %>
    <%- locals = {:f => f} %>
    <p>
      <%= t(".company") %><br />
      <%= f.text_field :company_cont, :size=>18 %>
    </p>
    <p>
      <%= t(".buyer_contact") %><br />
      <%= f.text_field :buyer_contact_cont, :size=>18 %>
    </p>
    <p>
      <%= t(".manager_contact") %><br />
      <%= f.text_field :manager_contact_cont, :size=>18 %>
    </p>
    <p>
      <%= t("phone") %><br />
      <%= f.text_field :phone_cont, :size=>18 %>
    </p>
    <p>
      <%= t(".notes") %><br />
      <%= f.text_field :notes_cont, :size=>18 %>
    </p>

    <p><%= button t("search") %></p>
  <% end %>
</div>
<% end %>
